<?php $post = $this->get("post");?>
<div class="x-list-title">
<table height="100%" width="100%" border="0" cellpadding="0">
<tr><td>
<h2>Chi tiết dự án</h2>
</td><td align="right">
<div class="x-list-options">	
	<a href="#Task/Index/Add?project_id=<?php _e($post['ID'])?>" class="x-button">Giao việc</a>
	<a onclick="load_inframe('<?php _baseUrl();?>/Project/Index/Sms?ID=<?php _e($post['ID'])?>',{auto_hidden:true,title: 'Nhắc nhở SMS',id: '<?php _e(getId())?>' })" class="x-button x-button-add">Gửi SMS</a>
	<div class="x-options-container">
		<a class="x-button">Trạng thái <span>&#9660;</span></a>
		<div class="x-options">
			<a onclick="ajax_load('<?php _baseUrl()?>/Project/Index/Status?ID=<?php _e($post['ID'])?>&status=complete')" class="x-options-item">Hoàn thành</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Project/Index/Status?ID=<?php _e($post['ID'])?>&status=inactive')" class="x-options-item">Tạm dừng</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Project/Index/Status?ID=<?php _e($post['ID'])?>&status=active')" class="x-options-item">Thực hiện</a>
			<a onclick="ajax_load('<?php _baseUrl()?>/Project/Index/Status?ID=<?php _e($post['ID'])?>&status=cancel')" class="x-options-item">Hủy bỏ</a>
		</div>
	</div>	
	<div class="x-options-container">
		<a class="x-button">Tác vụ khác <span>&#9660;</span></a>
		<div class="x-options">
			<a class="x-options-item" href="#Project/Track/Unread?ID=<?php _e($post['ID'])?>">Đánh dấu chưa đọc</a>
			<a href="#Project/Index/Edit?ID=<?php _e($post['ID'])?>" class="x-options-item">Sửa dự án</a>
			<a onclick="module_delete('<?php _baseUrl()?>/Project/Index/Delete?ID=<?php _e($post['ID'])?>')" class="x-options-item">Xóa dự án</a>
			<a href="#Project/Index/Add?ID=<?php _e($post['ID'])?>" class="x-options-item">Tạo dự án mới</a>
		</div>
	</div>
</div>
</td></tr></table>	
</div>
<table width="100%" border="0" class="x-info" cellspacing="0">
<tr>
	<td colspan="4" align="right" class="x-info-top">
		<span class="tl">Thông tin dự án</span>
		<span class="tr">Cập nhật lần cuối lúc <?php _e( show_date('H\h:i:s d/m/Y',$post['date_updated']) );?> bởi <?php _e(get_user_link($post['updated_by_id'],$post['updated_by_name'],$post['updated_is_deleted']))?></span>
	</td>
</tr>
<tr>
	<td class="x-info-label">
		Tên dự án
	</td>
	<td class="x-info-content">
		<span class="name"><?php _e( $post['title'] );?></span>
	</td>
	<td class="x-info-label" nowrap="nowrap">
		Số ngày thực hiện
	</td>
	<td class="x-info-content">
		<?php if( $post['dateof']) _e($post['dateof'].' ngày');?>
	</td>	
</tr>
<tr>
	<td class="x-info-label" nowrap="nowrap">
		Mã dự án
	</td>
	<td class="x-info-content">
		<span class="code"><?php _e( $post['code'] );?></span>
	</td>	
	<td class="x-info-label" nowrap="nowrap">
		Dự kiến kết thúc
	</td>
	<td class="x-info-content">
		<?php if( $post['date_end_forecast'] ):?>
		<?php _e( show_date(DATE_FORMAT,$post['date_end_forecast']) );?>
		<?php else:?>
		<i>Chưa xác định</i>
		<?php endif;?>		
	</td>
</tr>
<tr>
	<td class="x-info-label">
		Tiến độ
	</td>
	<td class="x-info-content">
		<div class="x-progress"><div title="<?php _e( (int)$post['rate'] );?>%" style="width:<?php _e( (int)$post['rate'] );?>%"></div></div>
		<?php _e( (int)$post['rate'] );?>%		
	</td>
	<td class="x-info-label" nowrap="nowrap">
		Kết thúc thực tế
	</td>
	<td class="x-info-content">
		<?php if( $post['date_end'] ):?>
		<?php _e( show_date(DATE_FORMAT,$post['date_end']) );?>
		<?php else:?>
		<i>Chưa xác định</i>
		<?php endif;?>
	</td>
</tr>
<tr>
	<td class="x-info-label">
		Ngày bắt đầu
	</td>
	<td class="x-info-content">
		<?php _e( show_date(DATE_FORMAT,$post['date_start']) );?>
	</td>
	<td class="x-info-label" nowrap="nowrap">
		Nhóm dự án
	</td>
	<td class="x-info-content">
		<a href="#Project/Index/Group?parent_id=<?php _e($post['parent_id'])?>"><?php _e($post['parent_title']);?></a>
	</td>	
</tr>	
<tr>
	<td class="x-info-label" nowrap="nowrap">
		Người phụ trách
	</td>
	<td class="x-info-content">
	<?php $a =array();?>
	<?php foreach( $this->get('users') as $u ):?>
	<?php if($u['is_supervisor'] =='yes' ):?>
	<?php $a[]=get_user_link($u);?>
	<?php endif;?>
	<?php endforeach;?>
	<?php _e( implode(', ',$a) );?>
	</td>
	<td class="x-info-label" nowrap="nowrap">
		Người được xem
	</td>
	<td class="x-info-content">
	<?php $a =array();?>
	<?php foreach( $this->get('users') as $u ):?>
	<?php if($u['is_guest'] =='yes' ):?>
	<?php $a[]=get_user_link($u);?>
	<?php endif;?>
	<?php endforeach;?>
	<?php _e( implode(', ',$a) );?>	</td>	
</tr>
<tr>
	<td class="x-info-label" nowrap="nowrap">
		Trạng thái
	</td>
	<td class="x-info-content">
	<?php _e( get_status($post['status']) );?>
	</td>	
	<td class="x-info-label" nowrap="nowrap">
		Người tạo
	</td>
	<td class="x-info-content">
	<?php _e(get_user_link($post['created_by_id'],$post['created_by_name'],$post['created_is_deleted']));?>
	</td>
</tr>
<tr>
	<td class="x-info-label" valign="top">
		Mô tả
	</td>
	<td colspan="3" class="x-info-content">
		<?php _e( $post['desc'] );?>
	</td>
</tr>	
<tr>
	<td class="x-info-label x-info-label-last">
		Đính kèm
	</td>
	<td colspan="3" class="x-info-content">
	<?php $a=array();?>
	<?php foreach( $this->get('files') as $f ):?>
	<?php show_thumb( $f, baseUrl()."/Project/Index/File?ID={$f['ID']}");?>
	<?php endforeach;?>	
	</td>
</tr>	
</table>
<div style="padding:2px"></div>
<?php $tasks = $this->get('tasks');?>
	<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
	<tr>
		<th width="25" align="center">
			TT
		</th>
		<th align="left">
			Công việc
		</th>
		<th align="center" width="100">
			Trạng thái
		</th>
		<th align="center" width="80">
			Tiến độ
		</th>
		<th align="center" width="100">
			Giao bởi
		</th>
		<th align="center">
			Hạn cuối
		</th>
		<th align="center" width="50" colspan="2">Tác vụ</th>
	</tr>	
	<?php if( count($tasks) == 0 ):?>
	<tr>
	<td colspan="8" class="page">
		<div class="x-page">
			Chưa có công việc nào được giao
		</div>
	</td>
	</tr>
	<?php endif;?>
<?php foreach( $tasks as $k => $a ):?>
	<?php $vars = $this->get('vars');?>
	<tr>
	<td align="center">
		<?php _e($k+1);?>
	</td>
	<td>
		<a href="#Task/Index/View?ID=<?php _e($a['ID']);?>"><?php _e(short_title($a['title'],$a['is_read']=='yes' ? 50 : 48));?></a>
	</td>
	<td align="center">
		<?php _e(get_status($a['status']));?>
	</td>
	<td align="center">
		<div class="progress-bg">
			<?php _e( max(0,min(100,$a['rate'])) );?> %
		</div>
	</td>

	<td align="center">
		<?php _e(get_user_link($a['created_by_id'],$a['created_by_name'],$a['created_is_deleted']));?>
	</td>
	<td width="120" align="center">
		<?php if( $a['date_end'] ):?>
			<?php if( strtotime($a['date_end']) < time() ):?>
			<div class="date_over"><span title="Lúc: <?php _e(date(TIME_FORMAT,strtotime($a['date_end'])));?>">
				<?php _e(show_date(DATE_FORMAT,$a['date_end']));?></span></div>
			<?php else:?>
			<span title="Lúc: <?php _e(show_date(TIME_FORMAT,strtotime($a['date_end'])));?>">
				<?php _e(show_date(DATE_FORMAT,$a['date_end']));?></span>
			<?php endif;?>
		<?php else: ?>	
		<i>Chưa xác định</i>
		<?php endif;?>
	</td>
	<td align="center" width="25">
		<?php if( $a['created_by_id'] == get_user_id() ):?>
		<a onclick="module_delete('<?php _baseUrl()?>/Task/Index/Delete?ID=<?php _e($a['ID'])?>&url_direct=<?php _e(rawurlencode("#Project/Index/View?ID=".$post['ID']))?>')" class="x-delete"></a>
		<?php else:?>
		<a class="x-nodelete"></a>
		<?php endif;?>
	</td>
	<td align="center" width="25">
		<?php if( $a['created_by_id'] == get_user_id() ):?>
		<a href="#Task/Index/Edit?ID=<?php _e($a['ID'])?>" class="x-edit"></a>
		<?php else:?>
		<a class="x-noedit"></a>
		<?php endif;?>
	</td>	
	</tr>
	<?php endforeach;?>
	</table>
	<!-- END LIST-->